﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class addEmployee : Form
    {
        List<string> names = new List<string>(); 
        ListBox parent;
        public addEmployee(ListBox parent)
        {
            InitializeComponent();
            this.parent = parent;
        }

        public addEmployee()
        {
            InitializeComponent();
        }

        private void informationSssLabel_Click(object sender, EventArgs e)
        {

        }

        private void addEmployeeCancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void addEmployeeButton_Click(object sender, EventArgs e)
        {
            if (addEmployeeFirstNameTextBox.Text.Equals("") || addEmployeeLastNameTextBox.Text.Equals("") || addEmployeeSalaryTextBox.Text.Equals("") ||
                addEmployeeWorkHoursTextBox.Text.Equals("") || addEmployeePayingBasisDropDownList.SelectedIndex == -1 || addEmployeePositionDropDownList.SelectedIndex == -1)
            {
                MessageBox.Show("No field should be empty.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                foreach (String strCol in parent.Items)
                {
                    names.Add(strCol);
                }
                names.Add(addEmployeeLastNameTextBox.Text + ", " + addEmployeeFirstNameTextBox.Text);
                parent.DataSource = names;
                this.Close();
            }
        }

        private void addEmployee_Load(object sender, EventArgs e)
        {

        }
    }
}
